var _PageSize=15;

$(function(){
    $('#btnSubmit').click(function () {_CurrentPage=1;ajaxGetList(true); });
	ajaxGetList(true);
})

function ajaxGetList(GetPageInfo) {
	_PageSize=$('#sltPage').val();
	$('#ajaxDataList').hide();
	$('#ajaxDataLoading').show();
	$.ajax({
	    type: "GET", 
	    url: "../location/list", 
	    data: "AjaxType=pagePageInfo&pageSize="+_PageSize+'&currentPage='+_CurrentPage
	    	+"&email="+$('#txtEmail').val()
	    	+"&name="+escape($('#txtName').val())
	        +"&time=" + new Date(), 
	    success: function (result) {
	    	// alert(result['pageInfo']);
	    	if(GetPageInfo)
	    	{
	    		pageInfoDisplay(result['pageInfo']);
	    	}
		    // alert(result);
		     var html="";
			 if(result.pageData.length>0) 
			 {
			  	var items=result['pageData'];
			  	for(var i=0;i<items.length;i++)
			  	{
			  	 	html+='<tr>';
			    	html+='<td>'+items[i].ids+'</td>';
			  	 	html+='<td class="auto">';
			  	 	html+=items[i].nickName+'</td>';
			  	 	// html+='<a href="#" onclick="showModal(\''+items[i]._id +'\')">'+items[i].nickName +'</a></td>';
			    	html+='<td>'+items[i].email+'</td>';
			    	// if(items[i].locationCount&&parseInt(items[i].locationCount)>0)
			    	// {

				  	 // 	html+='<td><a href="#" onclick="showModal(\''+items[i]._id +'\')">'+items[i].nickName +'</a></td>';
			    	// }else{
				    // 	html+='<td>'+items[i].locationCount+'</td>';
			    	// }
			    	html+='<td>'+items[i].locationCount+'</td>';
			    	html+='<td>'+(items[i].deviceCount?items[i].deviceCount:'0')+'</td>';
			    	html+='<td>'+(items[i].onlineCount?items[i].onlineCount:'0')+'</td>';
			    	html+='<td>'+(items[i].created?items[i].created:'')+'</td>';
			    	html+='<td><a href="#" onclick="showCountModal(\''+items[i]._id +'\')">查看详细</a></td>';
			    	html+='</tr>';

			  }
			}else
			{
	                html="<tr><td colspan='8'>未找到任何数据</td></tr>";
			}
			$('#ajaxDataList').html(html);
			$('#ajaxDataList').show();
			$('#ajaxDataLoading').hide();
		}
	});
}

function showModal(uuid){
	alert('没页面了……');
	 // $.fancybox({
  //       'autoResize': true,
  //       'type': 'iframe',
  //       'width':750,
  //       'height':550,
		// 'afterClose':ajaxGetList,
  //       'href': '/location/info/'+uuid        
  //   });
}

function showCountModal(uuid){
	 $.fancybox({
        'autoResize': true,
        'type': 'iframe',
        'width':800,
        'height':550,
		'afterClose':ajaxGetList,
        'href': '/location/shopCount/'+uuid        
    });
}